package com.yy.jhl.ui.main.activity;

import android.graphics.Color;

import com.yy.common.base.BaseActivity;
import com.yy.common.commonutils.SPUtils;
import com.yy.jhl.R;
import com.yy.jhl.app.AppConstant;
import com.yy.jhl.ui.manager.activity.MainWithCodeActivity;
import com.yy.jhl.ui.user.activity.LoginSelectActivity;
import com.yy.jhl.util.Configuration;
import com.yy.jhl.util.DataUtil;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created by Ellis.Li on 2017/7/11.
 */

public class SplashActivity extends BaseActivity {
    @Override
    public int getLayoutId() {
        return R.layout.act_splash;
    }

    @Override
    public void initView() {
        SetStatusBarColor(Color.parseColor("#3091F0"));
        //2S后执行
        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                initData();
            }
        }, 2000);
    }

    /**
     *
     */
    private void initData(){
        //初始化文件夹
        Configuration.initDirectoryPath();
        //判断是否登录
        if (!DataUtil.isLogin(mContext)){
            startActivity(LoginSelectActivity.class);
        }else if (SPUtils.getSharedIntData(mContext, AppConstant.SP_KEY_LOGIN_TYPE) ==  3){
            startActivity(MainWithCodeActivity.class);
        }else {
            startActivity(MainActivity.class);
        }
        finish();
    }
}
